package com.zdp.item.rest;

import com.zdp.common.result.ResultInfo;
import com.zdp.common.result.ResultInfoUtil;
import com.zdp.item.service.ItemService;
import com.zdp.item.service.ItemSpecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author sesshomaru
 * @date 2021/7/10 14:24
 */
@RestController
@RequestMapping("item")
public class ItemController {

    @Autowired
    private ItemService itemService;

    @Autowired
    private ItemSpecService itemSpecService;

    @Resource
    private HttpServletRequest httpServletRequest;

    @GetMapping("findItemList")
    public ResultInfo findItemList(@RequestParam String itemId) {
        return ResultInfoUtil.buildSuccess(httpServletRequest.getRequestURI(), itemService.findItemList(itemId));
    }

    @PostMapping("findItemsSpecListByItemId")
    public ResultInfo findItemsSpecListByItemId(@RequestParam String itemId) {
        return ResultInfoUtil.buildSuccess(httpServletRequest.getRequestURI(), itemSpecService.findItemsSpecListByItemId(itemId));
    }
}
